package com.foreverwin.jzymes.production.remedy.controller;

import com.foreverwin.jzymes.common.util.CommonMethods;
import com.foreverwin.jzymes.framework.base.AjaxResult;
import com.foreverwin.jzymes.framework.exception.BusinessException;
import com.foreverwin.jzymes.production.remedy.service.IRemedyAdviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/production/remedy")
public class RemedyController {

    @Autowired
    IRemedyAdviceService remedyAdviceService;

    @RequestMapping( "/save" )
    public AjaxResult doSave( @RequestParam String sourceTranship, @RequestParam String sourceItemType, @RequestParam String targetTranship, @RequestParam String targetItemType, @RequestParam Long trayQty ){
        try{
            String site = CommonMethods.getSite();

            remedyAdviceService.save( site, sourceTranship, sourceItemType, targetTranship, targetItemType, trayQty );
            return AjaxResult.returnSuccess();
        }catch ( BusinessException e ){
            return AjaxResult.returnError( e.getMessage() );
        }
    }
}
